{% extends 'TopxiaWebBundle:Coin:layout.html.twig' %}
{% block title %}我的{{setting('coin.coin_name')}} - {{ parent() }}{% endblock %}

{% set side_nav = 'my-coin' %}

{% block main %}
  <div class="es-section h400">
    {% include 'TopxiaWebBundle:Coin:bill-bar.html.twig' %}
    <span class="label label-primary label-md">账户余额</span>
    {% if setting('coin.coin_content') %}
      <a href="/coin/show" target="_blank" class="pull-right">{{setting('coin.coin_name')}}说明</a>
    {% endif %}
    <br>
    <div class="coin-block clearfix">
      <div class="coin-text">
        {% if setting('coin.coin_picture') %}
          <img class="coin-picture" src="{{asset(setting('coin.coin_picture')) }}" alt="虚拟币图片" width="30px" >
        {% endif %}
        <strong>{{account.cash|default(0)}}</strong>
      </div>

      {% if setting('coin.coin_enabled') %}
        <div class="coin-btn">
          {% if is_plugin_installed('ChargeCoin') and setting('coin.charge_coin_enabled') %}
            <a href="{{path('my_coin_buy')}}" target="_blank" class="mll btn btn-primary"> &nbsp;&nbsp;充&nbsp;值&nbsp;&nbsp; </a>
          {% endif %}
          {% if is_plugin_installed('MoneyCard') %}
            <a href="{{path('money_card_use')}}" target="_blank" class="mll btn btn-default">使用学习卡</a>
          {% endif %}
        </div>
      {% endif %}
    </div>
    <hr>
    <ul class="nav nav-pills" role="tablist">
      <li role="presentation" {% if app.request.query.get('type') != "inflow" and app.request.query.get('type') != "outflow" %}class="active"{% endif %}><a href="{{path('my_coin',{type:''})}}">全部记录</a></li>
      <li role="presentation" {% if app.request.query.get('type') == "inflow" %}class="active"{% endif %}><a href="{{path('my_coin',{type:'inflow'})}}">充值记录</a></li>
      <li role="presentation" {% if app.request.query.get('type') == "outflow" %}class="active"{% endif %}><a href="{{path('my_coin',{type:'outflow'})}}">消费记录</a></li>
    </ul>
    <br>
    <form id="user-search-form" class="form-inline well well-sm clearfix" action="" method="get" novalidate> 
      <div class="form-group"> 
        <input type="hidden" name="type" value="{{ app.request.query.get('type')|default('') }}">
        <select class="form-control" name="lastHowManyMonths" onchange="submit();"> 
          {% set options = {'':'全部记录','oneWeek':'最近一周','twoWeeks':'最近两周','oneMonth':'最近一个月','twoMonths':'最近两个月','threeMonths':'最近三个月'} %}
          {{ select_options(options, app.request.get('lastHowManyMonths')) }} 
        </select> 
      </div> 

      <div class="control-label pull-right" style="padding-top: 8px;">
        {% if app.request.query.get('type') != "outflow"  %}
          收入：<span style="color:#1bb974;">{{ amountInflow }}</span>&nbsp;{{setting('coin.coin_name')}}
        {% endif %}
        {% if app.request.query.get('type') != "inflow"  %}
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          支出：<span style="color:#ff7b0e;">{{ amountOutflow }}</span>&nbsp;{{setting('coin.coin_name')}}
        {% endif %}
      </div>
    </form>
    <br>
    <div class="table-responsive">
      <table class="table table-striped">
        {% if cashes %}
        <tr>
          <th><span class="text-sm">流水号</span></th>
          <th><span class="text-sm">名称</span></th>          
          <th><span class="text-sm">成交时间</span></th>          
          <th class="text-right" style="padding-right: 60px;"><span class="text-sm">收支</span></th>
          <th><span class="text-sm">支付方式</span></th>
        </tr>
        {% for cash in cashes %}
          <tr>
            <td><span class="text-sm">{{cash.sn}}</span></td>
            <td><span class="text-sm">{{cash.name}}</span><br>
                <span class="text-muted text-sm">订单号：{{cash.orderSn}}</span></td>            
            <td><span class="text-sm">{{cash.createdTime|date('Y-m-d H:i:s')}}</span></td>

            {% if cash.type =="inflow" %}
            <td class="text-right" style="color:#1bb974;padding-right: 50px;">
               {{cash.amount}} 
            </td>
            {% endif %}
            {% if cash.type =="outflow" %}
            <td  class="text-right" style="color:#ff7b0e;padding-right: 50px;">
               -&nbsp;{{cash.amount}}               
            </td>
            {% endif %}

            <td>
              <span class="text-sm">
                {% if cash.cashType == "Coin" and cash.category == "inflow" %}
                学习卡充值
                {% elseif cash.cashType == "Coin" and cash.category == "change" %}
                  {% if cash.payment == 'wxpay' %}
                  微信支付
                  {% elseif cash.payment == 'alipay' %}
                  支付宝支付
                  {% endif %}
                {% elseif cash.category == "moneyCardRecharge" %}
                学习卡
                {% else %}
                余额支付             
                {% endif %}
              </span>
            </td>
          </tr>
        {% endfor %}
        {% else %}
          <div class="empty">暂无记录</div>
        {% endif %}
      </table>
    </div>
    <nav class="text-center">
      {{ web_macro.paginator(paginator) }}
    </nav>
  </div>
{% endblock %}